<?php
	include("initialize.php");
?>
<html>
	<head>
		<title>GradeGrid - Make New Class</title>
		<script type="text/javascript" language="javascript">
		
		</script>
		<link rel="stylesheet" type="text/css" href="new.css" />
	</head>
	<body>
		<?php include("write_functions.php");
		connect('localhost','root','','gradegriddatabase');?>
		<form action="success_new_class.php" name="new_class" method="post">
			Section name:<br />
			<input type="text" name="section"/><br />
			
			Time:<br />
			<input type="text" name="start" /> to <input type="text" name="end" /><br />
			
			Day:<br />
			<input type="checkbox" value="SN" name="days[]" id="sunday"><label for="sunday">Sunday</label><br />
			<input type="checkbox" value="M" name="days[]" id="monday"><label for="monday">Monday</label><br />
			<input type="checkbox" value="T" name="days[]" id="tuesday"><label for="tuesday">Tuesday</label><br />
			<input type="checkbox" value="W" name="days[]" id="wednesday"><label for="wednesday">Wednesday</label><br />
			<input type="checkbox" value="TH" name="days[]" id="thursday"><label for="thursday">Thursday</label><br />
			<input type="checkbox" value="SN" name="days[]" id="friday"><label for="friday">Friday</label><br />
			<input type="checkbox" value="SN" name="days[]" id="sunday"><label for="sunday">Sunday</label><br />
		<br />Template: <br />
		
		<?php
			
			$accountid_query = sprintf("SELECT account_id FROM account WHERE username = '%s'",
		                                mysql_real_escape_string($_SESSION["username"]));
			$accountid_array = mysql_fetch_array(mysql_query($accountid_query));
			$accountid = mysql_real_escape_string($accountid_array["account_id"]);
			
			$index=0;
			$query_template = sprintf("SELECT * FROM template WHERE account_id = '%s'",
			                          $accountid);
			$result_template=mysql_query($query_template);
			$num=mysql_numrows($result_template);
			while ($index<$num){
				$template_name=mysql_result($result_template,$index,"template_name");
				echo "<input type='radio' name='template' value='$template_name'><font face='Verdana' size='2'>$template_name</font><br>";			//other templates
				$index++;
			}
			echo "<input type='radio' name='template' value='none'><font face='Verdana' size='2'>None</font><br>";	?>
		<br /> Make a class for : <br />
		 <?php $index=0;
			$query_course = sprintf("SELECT course_name FROM course WHERE account_id = '%s'",
			                        $accountid);
			$result_course=mysql_query($query_course);
			$num=mysql_numrows($result_course);
			
			while ($index<$num){
				$course_name=mysql_result($result_course,$index,"course_name");
				echo "<input type='radio' name='course' value='$course_name'><font face='Verdana' size='2'>$course_name</font><br>";			//other templates
				$index++;
			}
			//echo "<input type='radio' name='course' value='none'><font face='Verdana' size='2'>None</font><br>";
			if($num == 0){
				echo "<script type='text/javascript' language='javascript'>\n";
				echo "alert('You don\'t have any courses yet. Please open a course first.')\n";
				echo "window.close()\n";
				echo "</script>";
			}
		?>
		
		<br />
		<input type="submit" value="Save" name="saveNewClass" /> 
		</form>
	</body>
</html>